// Package rpcServer
/*
@Coding : utf-8
@Time : 2023/3/11 16:37
@Author : yizhigopher
@Software : GoLand
*/
package rpcServer

import (
	"ginchat/internal/pb"
	"ginchat/internal/rpcServer/services"
	"ginchat/utils/errorx"
	"ginchat/utils/message"
	"google.golang.org/grpc"
	"net"
)

func startTokenServer() {
	listen, err := net.Listen("tcp", ":"+cfg.GetString("tokenService.port"))
	if err != nil {
		errorx.ErrorExit(err)
	}

	tokenServer := grpc.NewServer()
	registerTokenService(tokenServer)

	message.Println("rpc service[token service] is up...")
	_ = tokenServer.Serve(listen)
	message.PrintWarn("rpc service[token service] close")
}

func registerTokenService(server *grpc.Server) {
	pb.RegisterTokenServiceServer(server, &services.TokenService{})
}
